import platform = require('../../../../../../platform/common/baseCommon');
import appClient = require('../../../../../../platform/client/appClient');
import platformControls = require('../../../../../../platform/client/controls');
import report = require('../../../../../../platform/client/report');

// 数据服务
let dataService1 = new appClient.asyncFactory(platform.IDataService, "remoteCall", "gongshangService");

// 数据获取器
/** 获取器:纳税人信息 */
let fetcher_investor_info = new report.dataServiceFetcher();
fetcher_investor_info.name = "fetcher_investor_info";
fetcher_investor_info.command = "cmd_investor_info";
fetcher_investor_info.dataService = dataService1;


// 数据获取器
let fetcher_RG_investor_info = new report.dataServiceFetcher();
fetcher_RG_investor_info.name = "fetcher_RG_investor_info";
fetcher_RG_investor_info.command = "cmd_RG_investor_info";
fetcher_RG_investor_info.dataService = dataService1;

let fetcher_RG_investor_info_by_enterprise = new report.dataServiceFetcher();
fetcher_RG_investor_info_by_enterprise.name = "fetcher_RG_investor_info_by_enterprise";
fetcher_RG_investor_info_by_enterprise.command = "cmd_RG_investor_info_by_enterprise";
fetcher_RG_investor_info_by_enterprise.dataService = dataService1;

let fetcher_RG_enterprise_info_by_person = new report.dataServiceFetcher();
fetcher_RG_enterprise_info_by_person.name = "fetcher_RG_enterprise_info_by_person";
fetcher_RG_enterprise_info_by_person.command = "cmd_RG_enterprise_info_by_person";
fetcher_RG_enterprise_info_by_person.dataService = dataService1;

// 数据源
/** 数据源:纳税人信息 */
let dataSource_RG_investor_info = new platform.dataQuerySource();
dataSource_RG_investor_info.name = "dataSource_RG_investor_info";
dataSource_RG_investor_info.fetcher = fetcher_RG_investor_info;
dataSource_RG_investor_info.paramKeyList = {
    "TYPE_FLAG": "投资人性质",
    "CERTID": "证照号码",
    "INVESTORNAME": "投资人名称"
};

let paramKeyListRG = {
    "TYPE_FLAG": "TYPE_FLAG",
    "CERTID": "CERTID",
    "INVESTORNAME": "SHOWNAME",
    "CORPNAME": "SHOWNAME"
};


// 数据源
/** 数据源：投资人信息 */
let dataSource_investor_info = new platform.dataQuerySource();
dataSource_investor_info.name = "dataSource_investor_info";
dataSource_investor_info.fetcher = fetcher_investor_info;

//字段编辑器
/**
 * 纳税人名称
 */
let investorNameFieldEdit = new report.fieldEditInfo();
investorNameFieldEdit.name = "INVESTORNAME";
let investorNameControl = new platformControls.fieldEditControl();
investorNameControl.frontLabel = "投资人名称";
investorNameFieldEdit.editControl = investorNameControl;

/**
 * 投资人投资企业个数
 */
let investNumberFieldEdit = new report.fieldEditInfo();
investNumberFieldEdit.name = "INVESTNUMBER";
let investNumberControl = new platformControls.fieldEditControl();
investNumberControl.frontLabel = "投资人投资企业个数";
investNumberFieldEdit.editControl = investNumberControl;

/** 数据显示器:参数输入 */
let paramReport = new report.parameterControl();

paramReport.name = "report_xkzzsfpqyfx_parameters";
paramReport.fields = [investorNameFieldEdit,investNumberFieldEdit];
paramReport.caption = "查询条件";
paramReport.dataSourceNames = ["dataSource_investor_info"];
paramReport.dataViews = {};
paramReport.queryCount = 500;


//数据显示器
/** 数据显示器:投资人列表 */
let tableReport_investor_info = new report.gridDataDisplayer();
tableReport_investor_info.name = "report_investor_info";
tableReport_investor_info.caption = "投资人列表";
tableReport_investor_info.dataSourceNames = ["dataSource_RG_investor_info"];
tableReport_investor_info.dataViews = {};
let tableView_investor_info = new platform.dataView();
tableView_investor_info.dataSourceName = "dataSource_investor_info";
tableReport_investor_info.dataViews["view_table"] = tableView_investor_info;
//tableReport_investor_info.groupName = "group_nsrxx";

/** 关系图数据显示器：企业商业族谱 */
let tableReport_RelationGraph = new report.echartRelationGraphDataDisplayer();
tableReport_RelationGraph.name = "report_xkzzsfpqyfx_RelationGraph";
tableReport_RelationGraph.caption = "企业商业族谱";
tableReport_RelationGraph.dataSourceNames = [];
tableReport_RelationGraph.dataViews = {};
let tableView_RelationGraph = new platform.dataView();
tableView_RelationGraph.dataSourceName = "dataSource_RG_investor_info";
tableReport_RelationGraph.dataViews["view_table"] = tableView_RelationGraph;
tableReport_RelationGraph.groupName = "group_nsrxxmx";
tableReport_RelationGraph.style("height", 355);

tableReport_RelationGraph.draggable = true;

tableReport_RelationGraph.fetchers = {
    "自然人": fetcher_RG_enterprise_info_by_person,
    "企业": fetcher_RG_investor_info_by_enterprise
};
tableReport_RelationGraph.fetcherField = "INVESTOR_CATEGORY";
tableReport_RelationGraph.paramKeyList = paramKeyListRG;

tableReport_RelationGraph.extendsFields = [
    "CERTID"
];

tableReport_RelationGraph.showField = "SHOWNAME";

tableReport_RelationGraph.linePointing = {
    "投资": "被投资"
};
tableReport_RelationGraph.linePointingFiled = "CATEGORY";


tableReport_RelationGraph.options = {
    title: {
        text: ''
    },
    animationDurationUpdate: 1500,
    animationEasingUpdate: 'quinticInOut',
    label: {
        normal: {
            show: true,
            position: 'bottom',
            textStyle: {
                fontSize: 8
            }
        }
    },
    legend: {
        data: ["自然人", "企业"]
    },
    series: [
        {
            "type": 'graph',
            "layout": 'force',
            symbolSize: 40,
            focusNodeAdjacency: true,
            roam: true,
            force: {
                repulsion: 1500
            },
            label: {
                normal: {
                    show: true,
                    textStyle: {
                        fontSize: 12
                    }
                }
            },
            edgeSymbol: ['none', 'arrow'],
            edgeSymbolSize: [4, 10],
            lineStyle: {
                normal: {
                    opacity: 0.9,
                    width: 1,
                    curveness: 0
                }
            },
            categories: [{ name: "自然人" }, { name: "企业" }],
            itemStyle: {
                emphasis: {
                    borderColor: 'rgb(238,201,0)',
                    borderWidth: 5,
                    opacity: 0
                }
            },
            data: [],
            links: [],
            animationDelay: function (idx: number) {
                return idx * 100;
            }
        }
    ],
    animationDelayUpdate: function (idx: number) {
        return idx * 100;
    }
};
/**
 * 佛山国税智能报表
 * @description 虚开增值税发票企业分析
 */
export let defaultObject = new report.smartReport();
defaultObject.caption = "佛山市企业商业族谱";
defaultObject.dataSources = {};
defaultObject.dataSources[dataSource_investor_info.name] = dataSource_investor_info;
defaultObject.dataSources[dataSource_RG_investor_info.name] = dataSource_RG_investor_info;
defaultObject.layoutPanel = new platformControls.layoutPanel("project/test/config/client/smartReportApp/layout/layout.html");
defaultObject.modules = {};
defaultObject.modules[paramReport.name] = paramReport;
defaultObject.modules[tableReport_investor_info.name] = tableReport_investor_info;
defaultObject.modules[tableReport_RelationGraph.name] = tableReport_RelationGraph;

defaultObject.autoQuery = false;





